
#ifndef _INTERRUPT_H_
#define _INTERRUPT_H_

#define save_flags(flags) \
  asm volatile("pushfl ; popl %0":"=g"(flags)::"memory")
#define restore_flags(flags) \
  asm volatile("push %0; popfl"::"g"(flags):"memory")


#define disable_IRQs(flags)    \
  ({ save_flags(flags); asm("cli\n"); })
#define restore_IRQs(flags)    \
  restore_flags(flags)


#define EXCEPT_DIVIDE_ERROR                  0         
#define EXCEPT_DEBUG                         1         
#define EXCEPT_NMI_INTERRUPT                 2         
#define EXCEPT_BREAKPOINT                    3        
#define EXCEPT_OVERFLOW                      4        
#define EXCEPT_BOUND_RANGE_EXCEDEED          5        
#define EXCEPT_INVALID_OPCODE                6         
#define EXCEPT_DEVICE_NOT_AVAILABLE          7       
#define EXCEPT_DOUBLE_FAULT                  8       
#define EXCEPT_COPROCESSOR_SEGMENT_OVERRUN   9        
#define EXCEPT_INVALID_TSS                  10       
#define EXCEPT_SEGMENT_NOT_PRESENT          11        
#define EXCEPT_STACK_SEGMENT_FAULT          12        
#define EXCEPT_GENERAL_PROTECTION           13         
#define EXCEPT_PAGE_FAULT                   14         
#define EXCEPT_INTEL_RESERVED_1             15         
#define EXCEPT_FLOATING_POINT_ERROR         16        
#define EXCEPT_ALIGNEMENT_CHECK             17      
#define EXCEPT_MACHINE_CHECK                18   

     

#endif
